<?php

class Field extends Eloquent {
	/**
	 * The database table used by the model.
	 *
	 * @var string
	 */
	protected $table = 'field';

	/**
	 * Fetches all the matches that were played in the Field 
	 *
	 * @return Match array
	 */
	public function matches()
    {
        return $this->hasMany('Match', 'fieldId', 'id');
    }
    
    /**
     * Fetches all the match types that can be played in the Field
     *
     * @return MatchType array
     */
    public function types()
    {
    	return $this->belongsToMany('MatchType', 'field_matchtypes', 'fieldId', 'matchTypeId');
    }
}
